<script type="text/javascript">
	$(function(){
		//初始化页面
		load();
		
		//分组查询
		$(".divide").click(function(){
			load($(this).val());
		});
		
		
		
		//添加任务
		$(".taskfrom").submit(function(){
			$.post("addtask",$(this).serialize(),function(data){
				if(data.flag){
					alert("添加成功");
				}else{
					alert("添加失败");
				}
			});
		});
		
		
		//介绍任务详情
		$('.task_js').hover(function(e) {  
		    var pageX=e.pageX;          
		    var pageY=e.pageY;         
		    $("#task_int").css("top",pageY);
			$("#task_int").css("left",pageX);
			$("#task_int").css("display","block");
			$("#js").html($(this).html());
		},
		function(){
			$("#task_int").css("display","none");
		});
		
		$("#task_btn").click(function(){
			$(".addTask").css("display","block");
			$("#all").css("display","block");
		});
		
	});
	
	//定义函数区
	//删除任务
	function Tdelet(id){
		$.post("deletTask",{id:id},function(data){
			if(data.flag){
				alert("删除成功");
			}else{
				alert("删除失败");
			}
			
		});
		load();
	}
	
	
	//初始化页面
	function load(divide){
		$.post("SelectTask",{divide:divide},function(data){
			var tk = '';
			for(var i=0;i<data.length;i++){
			var tk1 ='<tr>'+
			      '<td>'+data[i].taskname+'</td>'+
			      '<td><div style="width:200px; height:20px; overflow:hidden;" class="task_js">'+data[i].taskintd+'</div></td>'+
			      '<td>'+data[i].divide+'</td>'+
				  '<td>'+data[i].stime+'</td>'+
				  '<td>'+data[i].etime+'</td>'+
				  '<td>'+data[i].taskstatus+'</td>'+
				  '<td><a href="javascript:Tdelet('+data[i].id+')"><button type="button" class="btn btn-warning btn-xs">删除</button></a></td>'+
			    '</tr>'
			    tk+=tk1;
			}
			$(".task_select").html(tk);
		});
	}
	
</script>
<div>
	<h3>任务管理</h3>
	<!--菜单栏-->
	<div class="col-lg-9">
		<button type="button" class="btn btn-primary" id="task_btn">新建任务</button>
		<button type="button" class="btn btn-success divide" value="图片组">图片组任务</button>
		<button type="button" class="btn btn-success divide" value="信息组">信息组任务</button>
	</div>
</div>

<div id="task_int">
	<span id="js"></span>
</div>

<!--列表栏-->
<table class="table table-striped" style="margin-bottom: 0px;">
	<caption>任务列表</caption>
	<thead>
		<tr>
			<th>任务名称</th>
			<th>任务介绍</th>
			<th>所属分组</th>
			<th>发起时间</th>
			<th>结束时间</th>
			<th>任务状态</th>
		</tr>
	</thead>
	<tbody class="task_select">

	</tbody>
</table>
<!--分页-->
<div class="fenye" style="margin-bottom: 0px; text-align: center;">
	<nav aria-label="Page navigation">
		<ul class="pagination">
			<li><a href="#" aria-label="Previous"> <span
					aria-hidden="true">&laquo;</span>
			</a></li>
			<li><a href="#">1</a></li>
			<li><a href="#" aria-label="Next"> <span aria-hidden="true">&raquo;</span>
			</a></li>
		</ul>
	</nav>
</div>

<!--添加任务表单-->
<div class="addTask">
	<h3>请填写任务信息</h3>
	<form class="taskfrom">
		<div class="form-group">
			<label for="exampleInputEmail1">任务名</label> <input type="text"
				class="form-control" id="task_name" placeholder="任务名"
				name="taskname">
		</div>
		<div class="form-group">
			<label for="exampleInputEmail1">任务介绍</label>
			<textarea class="form-control" id="task_ind" placeholder="任务介绍"
				name="taskintd"></textarea>
		</div>
		<div class="form-group">
			<label for="exampleInputEmail1">结束时间</label> <input type="text"
				class="form-control" id="password" placeholder="1998/01/01"
				name="etime">
		</div>
		<div class="form-group" style="padding-left: 50px;">
			<label for="exampleInputPassword1">所属分组</label> <input type="radio"
				name="divide" value="图片组"> <label
				for="exampleInputPassword1">图片组</label> <input type="radio"
				name="divide" value="信息组"> <label
				for="exampleInputPassword1">信息组</label>
		</div>
		<button type="submit" class="btn btn-default">提交</button>
	</form>
</div>
<div id="all"></div>

</div>
